package org.lanqiao.netctoss.controller.service;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.lanqiao.netctoss.entity.Buss;
import org.lanqiao.netctoss.entity.Tariff;
import org.lanqiao.netctoss.service.impl.BussServiceImpl;

/**
 * Servlet implementation class ServiceListServlet
 */
public class ServiceListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServiceListServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String os = "";
		String ip= "";
		String card="";
		int state=-2 ; 
		if(request.getParameter("os")!=null){
			os=request.getParameter("os");
		}
		if(request.getParameter("ip")!=null){
			ip=request.getParameter("ip");
		}
		if(request.getParameter("card")!=null){
			card=request.getParameter("card");
		}
		if(request.getParameter("state")!=null){
			state=Integer.parseInt(request.getParameter("state"));
		}
		System.out.println("1"+request.getParameter("os"));
		System.out.println("2"+request.getParameter("ip"));
		System.out.println("3"+request.getParameter("card"));
		System.out.println("4"+request.getParameter("state"));
		/*List<Buss> lb = new BussBussImpl().selBussByCondition(new Buss(card,os,state,ip));*/
		List<Buss> lb = new BussServiceImpl().selectBussByCondition(new Buss(card,os,state,ip));
		//List<Buss> lb =new BussServiceImpl().selectBuss();
		HttpSession session = request.getSession();
		session.setAttribute("lb", lb);		
		if(lb!=null){
			RequestDispatcher rd =request.getRequestDispatcher("../view/service/service_list.jsp");
			rd.forward(request, response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
